from django.shortcuts import render
from django.db import connection
from django.http import HttpResponse
import json
# Create your views here.


def test_query_sql(request):
    query_sql = request.GET.get('sql')
    # 获取对象
    cursor = connection.cursor()
    # 拿到对象后执行sql语句
    cursor.execute(query_sql)
    # 获取所有的数据
    rows = cursor.fetchall()
    # 追历查询到的数据

    return HttpResponse(f'查找成功，结果集为:{rows}')

